package com.ruibang.glass.equipment.controller;


import com.ruibang.glass.equipment.constant.Constants;
import com.ruibang.glass.equipment.domain.req.device.PressureVesselPageReq;
import com.ruibang.glass.equipment.entity.device.PressureVessel;
import com.ruibang.glass.equipment.entity.device.ScrapReport;
import com.ruibang.glass.equipment.service.PressureVesselService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * <p>
 *压力容器
 * </p>
 *
 * @author mameng
 * @since 2024-03-20
 */
@RestController
@RequestMapping("/api/equipment/pressure/vessel")
@Api(value = "压力容器")
public class PressureVesselController {
    @Autowired
    private PressureVesselService pressureVesselService;

    @PostMapping("list")
    @ApiOperation(value = "获取压力容器列表", response = ResultBody.class)
    public ResultBody getBoilerList(@RequestBody PressureVesselPageReq boilerInfo) {
        return ResultBody.success(pressureVesselService.queryPressureVesselList(boilerInfo));
    }

    @PostMapping("/deleteById")
    @ApiOperation(value = "删除实体", response = ResultBody.class)
    public ResultBody deleteById(@RequestBody PressureVessel boilerInfo) {
        pressureVesselService.lambdaUpdate().set(PressureVessel::getIsDelete, Constants.ONE_STR).eq(PressureVessel::getId, boilerInfo.getId()).update();
        return ResultBody.success();
    }

    @PostMapping("/getPressureVesselById")
    @ApiOperation(value = "获取对象", response = ResultBody.class)
    public ResultBody getBoilerInfoById(@RequestBody PressureVessel boilerInfo) {
        PressureVessel byId = pressureVesselService.getById(boilerInfo.getId());
        return ResultBody.success(byId);
    }

    @PostMapping("/updateBoilerInfo")
    @ApiOperation(value = "更新", response = ResultBody.class)
    public ResultBody updateBoilerInfo(@RequestBody PressureVessel boilerInfo) {
        return ResultBody.success(pressureVesselService.updateOrAddById(boilerInfo));
    }

    @PostMapping("/getContainerCategory")
    @ApiOperation(value = "获取类别", response = ResultBody.class)
    public ResultBody getContainerCategory() {
        return ResultBody.success(pressureVesselService.getContainerCategory());
    }

}
